<script setup>
import { useRouter} from 'vue-router'
import info_svg from "../assets/images/student/info.svg"

// 传入课程
const props = defineProps(['itemName', 'itemIntroduction', 'itemId', 'buttons', 'params'])

const router = useRouter()

// function getDetail(subject_id) {
//     router.push({name: 'subject_detail', params:{subject_id}})

// }

const emit = defineEmits(['getMyJoinedCourses']);


</script>

<template>
    <div class="card">
        <div class="card-header">
            <div class="header-img">
                <img :src="info_svg" alt="info logo"  />
            </div>
            <div class="header-title" >{{props.itemName}}</div>
            <div class="header-abstract" ><p>{{props.itemIntroduction}}</p></div>
                
                
            
        </div>
        <div class="card-footer">
            <template v-for="(btn, index) in props.buttons" >
                <button type="button" @click="() => btn.func.bind({emit}, props.params[index])()" >{{$t(btn.text)}}</button>
                <span v-if="(index+1)!=props.buttons.length" ></span>
            </template>
        </div>
    </div>
</template>


<style scoped >
.card {
    display: grid;
    box-shadow: 2px 3px 6px 0px rgba(0, 0, 0, 0.16);
    width: 290px;
    height: 151px;
    border-radius: 10px;
    background:  linear-gradient(180deg,#ffffff 111px , #dbdde3 40px);
    grid-template-rows: 111px 40px;
    grid-template-areas: "header" "footer";
}

.card-header {
    grid-area: header;
    padding: 10px;
    display: grid;
    grid-template-areas: 
    "img title" 
    "img abstract";
    grid-template-columns: 50px calc(100% - 50px);
    grid-template-rows: 50px calc(100% - 50px);
}

.header-img {
    grid-area: img;
    text-align: center;
}

.header-title {
    grid-area: title;
    font-family: Source Han Sans CN;
	font-size: 18px;
    font-weight: bold;
	color: #707070;
    padding-left: 18px;
    overflow-x: hidden;
}

.header-abstract {
    grid-area: abstract;
    font-family: Source Han Sans CN;
	font-size: 12px;
	color: #707070;
    padding-left: 18px;
}

.card-footer {
    grid-area: footer;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
}

.card-footer button {
    height: 40px;
    width: 64px;
    line-height: 40px;
    cursor: pointer;
    color: #707070;
    font-size: 14px;
    font-family: Source Han Sans CN;
    border: none;
    outline: none;
    background-color: transparent;
    padding: 0;
    text-align: center;
}


.card-footer button:hover {
    opacity: 0.8;
}

.card-footer button:active {
    transform: translateY(3px);
}

.card-footer span {
    display: inline-block;
    height: 32px;
    border-width: 0px 1px 0px 1px;
    border-style: solid;
    border-color: #707070;
    opacity: 0.52;
}



</style>